package com.ruoyi.develop.payApplyDaohuo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.develop.payApplyDaohuo.domain.PayApplyDaohuo;
import com.ruoyi.develop.payApplyDaohuo.service.IPayApplyDaohuoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 付款申请和到货关系Controller
 * @author lmm
 * @date 2024-10-15
 */
@RestController
@RequestMapping("/payApplyDaohuo/payApplyDaohuo")
public class PayApplyDaohuoController extends BaseController {
    @Autowired
    private IPayApplyDaohuoService payApplyDaohuoService;

    /**
     * 查询付款申请和到货关系列表
     */
    @PreAuthorize("@ss.hasPermi('develop:PayApplyDaohuo:query')")
    @GetMapping("/list")
    public TableDataInfo list(PayApplyDaohuo entity) {
        startPage();
        List<PayApplyDaohuo> list = payApplyDaohuoService.selectList(entity);
        return getDataTable(list);
    }

    /**
     * 导出付款申请和到货关系列表
     */
    @PreAuthorize("@ss.hasPermi('develop:PayApplyDaohuo:export')")
    @Log(title = "付款申请和到货关系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PayApplyDaohuo entity) {
        List<PayApplyDaohuo> list = payApplyDaohuoService.selectList(entity);
        ExcelUtil<PayApplyDaohuo> util = new ExcelUtil<PayApplyDaohuo>(PayApplyDaohuo. class);
        util.exportExcel(response, list, "付款申请和到货关系数据");
    }

    /**
     * 获取付款申请和到货关系详细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:PayApplyDaohuo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(payApplyDaohuoService.selectById(id));
    }

    /**
     * 新增付款申请和到货关系
     */
    @PreAuthorize("@ss.hasPermi('develop:PayApplyDaohuo:add')")
    @Log(title = "付款申请和到货关系", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody PayApplyDaohuo entity) {
        return toAjax(payApplyDaohuoService.insert(entity));
    }

    /**
     * 修改付款申请和到货关系
     */
    @PreAuthorize("@ss.hasPermi('develop:PayApplyDaohuo:edit')")
    @Log(title = "付款申请和到货关系", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody PayApplyDaohuo entity) {
        return toAjax(payApplyDaohuoService.update(entity));
    }

    /**
     * 删除付款申请和到货关系
     */
    @PreAuthorize("@ss.hasPermi('develop:PayApplyDaohuo:remove')")
    @Log(title = "付款申请和到货关系", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(payApplyDaohuoService.deleteByIds(ids));
    }
}
